<?php
/**
 * Created by PhpStorm.
 * User: merlin
 * Date: 15-10-15
 * Time: 下午6:17
 */
/**
 * L('domain', 'key', 'p1', 'p2', ....)
 * @return bool
 */
function L()
{
    $number = func_num_args();
    $params = func_get_args();
    if($number < 2) return false;

    static $LANG = array();
    $oKey = md5($params[0].$params[1]);

    if($LANG[$oKey]) return $LANG[$oKey];

    $text = dgettext(array_shift($params), array_shift($params));

    if($number > 2)
    {
        $search  = array();
        for($i=0; $i<count($params); $i++)
        {
            $search[] = "%$i";
        }

        $text = str_replace($search, $params, $text);
    }
    return $text;

}

$data=array(
    'from'=>'zh',
    'to'=>'en',
    'query'=>'科技',
    'transtype'=>'trans',
    'simple_means_flag'=>3
);
//百度翻译
/*$url = "http://fanyi.baidu.com/v2transapi";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
// post数据
curl_setopt($ch, CURLOPT_POST, 1);
// post的变量
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
$output = curl_exec($ch);
curl_close($ch);
//打印获得的数据
print_r($output);*/
